﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RentAWorker.DataAccess.Interfaces;
using System.Data.Objects;
using RentAWorker.DataAccess.Entities;

namespace RentAWorker.DataAccess
{
    public class MachineTypeDataAccess : IMachineTypeAccess
    {
        public IEnumerable<MachineType> GetMachineType(string name)
        {
            using (BigDays2009Entities db = new BigDays2009Entities())
            {
                db.MachineType.MergeOption = MergeOption.NoTracking;

                return (from mt in db.MachineType
                        where (String.IsNullOrEmpty(name) 
                            || mt.MachineTypeName.StartsWith(name))
                        select mt).ToList();
            }
        }
    }
}
